<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); ?>

	<?php if($is_iphone) { ?>
    		<style>
				#main { width:1040px;float:left;margin:0px; }
			</style>
    		<table width="100%" cellpadding="0" cellspacing="0" border="0">
            	<tr>
                	<td>
                    	<?php get_sidebar(); ?>
                    </td>
                    <td>
        	<div id="primary" class="site-content">
		<div id="content" role="main">
        
        
        	<?php if (get_post_meta($post->ID, 'featuredproductsku', true)) { ?>
				
                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<header class="entry-header">
						<h1 class="entry-title"><?php the_title(); ?></h1>
                        <?php include 'social-block.php'; ?>
					</header>
                    
                    <?php // Call In The Featured Product For This Category
			echo do_shortcode('[product_category category="solar-lights" per_page="12" columns="4" orderby="date" order="desc"]'); ?>
                    
                    <div id="lpfeaturedproduct">
				
            	<?php $lpfeaturedproductsku = get_post_meta($post->ID, 'featuredproductsku', true);
				query_posts('post_type=product&meta_key=_sku&meta_value='.$lpfeaturedproductsku.'&posts_per_page=1');  ?>
					<?php if (have_posts()) { ?>
						<?php while (have_posts()) : the_post(); ?>
                        
                        	<?php
								$featuredproductsku = get_post_custom($post->ID);
								$fprodsku = $featuredproductsku['_sku'];
								foreach ( $fprodsku as $fprodsku );
								$featuredproductprice = get_post_custom($post->ID);
								$fprodprice = $featuredproductprice['_sale_price'];
								foreach ( $fprodprice as $fprodprice );
							?>
                        	
                            <?php if ( has_post_thumbnail() ) : ?>
								<a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) ) ?></a>
							<?php else : ?>
								<a href="<?php the_permalink(); ?>"><img src="<?php echo woocommerce_placeholder_img_src(); ?>" alt="Placeholder" width="200" align="left" /></a>
							<?php endif; ?>
                            
                            <h4 style="margin-bottom:10px;font-size:15px;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                            <ul style="height:30px;">
                            	<li class="first">SKU: <?php echo $fprodsku; ?></li>
                                <li>|</li>
                                <li><strong>Price: $<?php echo $fprodprice; ?></strong></li>
                            </ul>
                            <div style="width:100%;height:10px;clear:both;"></div>
                            <p><a class="button" href="<?php the_permalink(); ?>">View Details</a></p>
                        
						<?php endwhile ?>
					<?php } ?>
                    
                    </div><!-- #lpfeaturedproduct -->
                
                <?php while (have_posts()) : the_post(); ?>
                
                	<?php the_content(); ?>
                    
                <?php the_content(); ?>
                    
         	<?php endwhile; ?>
                    
				<?php } else { ?>
                
                	<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'content', 'page' ); ?>
					<?php endwhile; // end of the loop. ?>
            
            	<?php } ?>

		</div><!-- #content -->
	</div><!-- #primary -->
    			</td>
            </tr>
       </table>
   
        <?php } else { ?>
        
        <?php get_sidebar(); ?>
        
	<div id="primary" class="site-content">
		<div id="content" role="main">
        
        
        	<?php if (get_post_meta($post->ID, 'featuredproductsku', true)) { ?>
				
                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<header class="entry-header">
						<h1 class="entry-title"><?php the_title(); ?></h1>
					</header>
                    
                    <div id="lpfeaturedproduct">
				
            	<?php $lpfeaturedproductsku = get_post_meta($post->ID, 'featuredproductsku', true);
				query_posts('post_type=product&meta_key=_sku&meta_value='.$lpfeaturedproductsku.'&posts_per_page=1');  ?>
					<?php if (have_posts()) { ?>
						<?php while (have_posts()) : the_post(); ?>
                        
                        	<?php
								$featuredproductsku = get_post_custom($post->ID);
								$fprodsku = $featuredproductsku['_sku'];
								foreach ( $fprodsku as $fprodsku );
								$featuredproductprice = get_post_custom($post->ID);
								$fprodprice = $featuredproductprice['_sale_price'];
								foreach ( $fprodprice as $fprodprice );
							?>
                        	
                            <?php if ( has_post_thumbnail() ) : ?>
								<a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) ) ?></a>
							<?php else : ?>
								<a href="<?php the_permalink(); ?>"><img src="<?php echo woocommerce_placeholder_img_src(); ?>" alt="Placeholder" width="200" align="left" /></a>
							<?php endif; ?>
                            
                            <h4 style="margin-bottom:10px;font-size:15px;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                            <ul style="height:30px;">
                            	<li class="first">SKU: <?php echo $fprodsku; ?></li>
                                <li>|</li>
                                <li><strong>Price: $<?php echo $fprodprice; ?></strong></li>
                            </ul>
                            <div style="width:100%;height:10px;clear:both;"></div>
                            <p><a class="button" href="<?php the_permalink(); ?>">View Details</a></p>
                        
						<?php endwhile ?>
					<?php } ?>
                    
                    </div><!-- #lpfeaturedproduct -->
                
                <?php while (have_posts()) : the_post(); ?>
                
                	<?php the_content(); ?>
                    
                <?php the_content(); ?>
                    
         	<?php endwhile; ?>
                    
				<?php } else { ?>
                
                	<?php while ( have_posts() ) : the_post(); ?>
                    	
						<?php get_template_part( 'content', 'page' ); ?>
                        
					<?php endwhile; // end of the loop. ?>
            
            	<?php } ?>

		</div><!-- #content -->
        
	</div><!-- #primary -->

<?php } ?>

<?php get_footer(); ?>